import request from '@/utils/request'

// 查询机构管理列表
export function listHospital(query) {
  return request({
    url: '/institution/hospital/list',
    method: 'get',
    params: query
  })
}

// 查询机构管理详细
export function getHospital(hospitalId) {
  return request({
    url: '/institution/hospital/' + hospitalId,
    method: 'get'
  })
}

// 查询机构管理详细（包含科室信息）
export function getHospitalWithDepartments(hospitalId) {
  return request({
    url: '/institution/hospital/withDepartments/' + hospitalId,
    method: 'get'
  })
}

// 新增机构管理
export function addHospital(data) {
  return request({
    url: '/institution/hospital',
    method: 'post',
    data: data
  })
}

// 新增机构管理（包含科室）
export function addHospitalWithDepartments(data) {
  return request({
    url: '/institution/hospital/withDepartments',
    method: 'post',
    data: data
  })
}

// 修改机构管理
export function updateHospital(data) {
  return request({
    url: '/institution/hospital',
    method: 'put',
    data: data
  })
}

// 修改机构管理（包含科室）
export function updateHospitalWithDepartments(data) {
  return request({
    url: '/institution/hospital/withDepartments',
    method: 'put',
    data: data
  })
}

// 删除机构管理
export function delHospital(hospitalId) {
  return request({
    url: '/institution/hospital/' + hospitalId,
    method: 'delete'
  })
}

// 查询科室树形结构
export function listDepartmentTree() {
  return request({
    url: '/institution/department/tree',
    method: 'get'
  })
}

// 查询一级科室
export function listPrimaryDepartments() {
  return request({
    url: '/institution/department/primary',
    method: 'get'
  })
}

// 查询子科室
export function listChildrenDepartments(parentId) {
  return request({
    url: '/institution/department/children/' + parentId,
    method: 'get'
  })
}

// 上传机构Logo
export function uploadLogo(data) {
  return request({
    url: '/institution/hospital/uploadLogo',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}